package com.example.library.mapper;

import com.example.library.model.BookInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-20
 * Time: 16:55
 */
@Mapper
public interface BookInfoMapper {
    @Select("select * from book_info where status != 0 order by id desc limit #{offset}, #{pageSize}")
    List<BookInfo> selectBookInfoByPage(@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
    @Select("select count(*) from book_info where status != 0")
    Integer count();
    @Insert("insert into book_info (book_name, author, price, publish, count, status) values" +
            " (#{bookName}, #{author}, #{price}, #{publish}, #{status}, #{count})")
    Integer insertBook(BookInfo bookInfo);
    @Select("select id, book_name, author, count, price, publish, status from book_info where id = #{id}")
    BookInfo selectBookById(@Param("id") Integer id);
    Integer updateBook(BookInfo bookInfo);
    Integer deleteBook(@Param("ids") List<Integer> ids);
}
